local matRefraction	= Material( "refract_ring" )


//Initialize function
function EFFECT:Init(data)

self.Refract = 0 //Default value
self.Size = data:GetScale() //Retrieve effect size
self.Entity:SetRenderBounds(Vector()*-512, Vector()*512) //Optimisations

end


//Think function
function EFFECT:Think()

	//Make it bigger and denser
	self.Refract = self.Refract + FrameTime()

	//Kill if overdue
	if self.Refract >= 1 then return false end
	return true

end


//Render function
function EFFECT:Render()

	//Update material refraction value
	matRefraction:SetMaterialFloat("$refractamount", math.sin(self.Refract * math.pi) * 0.1)
	render.SetMaterial(matRefraction)
	render.UpdateRefractTexture()

	//Holy fuck what's going on here
	render.DrawSprite((self.Entity:GetPos() + (EyePos()-self.Entity:GetPos()):GetNormal() * EyePos():Distance(self.Entity:GetPos()) * (self.Refract^(0.3)) * 0.8), self.Size, self.Size)

end